/*
 *接口编写处...
*如果接口需要做Action的权限验证，请在Action上使用属性
*如: [ApiActionPermission("Blog",Enums.ActionPermissionOptions.Search)]
 */
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VOL.Entity.DomainModels;
using VOL.System.IServices;
using VOL.System.IRepositories;
using Autofac.Core;
using System.Linq;
using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Authorization;
using VOL.Core.Enums;
using VOL.Core.Filters;

namespace VOL.System.Controllers
{
    [Route("api/app_blogs")]
    public partial class BlogController
    {
        private readonly IBlogService _service;//访问业务代码
        private readonly IBlogRepository _blogRepository;

        [ActivatorUtilitiesConstructor]
        public BlogController(
            IBlogRepository blogRepository,
            IBlogService service
       
        )
        : base(service)
        {
            _service = service;
            _blogRepository = blogRepository;
        }
        [HttpGet, Route("getBlogList")]
        [ApiActionPermission("Sys_Menu2", ActionPermissionOptions.Search)]
        public async Task<IActionResult> GetBlogList()
        {
            var data = await _blogRepository.FindAsIQueryable(c => true)
                     .OrderByDescending(c => c.CreateDate)
                     .ToListAsync();
            return Json(data);

        }
    }
}
